home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr22
/
dtsav3.zip
/
DTSAV3.ASM
next >
Wrap
Assembly Source File
|
1993-05-01
|
4KB
|
147 lines
title DTSAV3 - write a .COM program to set current date and time
;
; Written by Jim Knutson, 13 Nov 1984.
; v2.0 : Vastly hacked and updated by David Kirschbaum, Toad Hall
; kirsch@braggvax.ARPA, 20 Oct 86.
; v3.0 : Changed again to produce a .COM program (faster than .BAT,
; running a .COM is cleaner than nesting .BAT files, etc.)
;
; DTSAV allows a programmer the ability of a faster boot when
; having to reboot a system by writing a file called DT.COM
; which contains commands to set the current date and time.
; If this is run immediately before executing a program that
; is being debugged, then DT.COM may be used to reset the date
; and time if the system hangs and must be rebooted. DT.COM
; may also be used to speed up a boot during the same day
; because only the time would have to be corrected.
;
; This particular version writes the program DT.COM to C: drive,
; root directory (where it's accessible for AUTOEXEC.BAT).
; Change the variable DTA below for your desired target drive\directory.
; To create DTSAV, use:
;
; MASM DTSAV;
; LINK DTSAV;
; EXE2BIN DTSAV
; REN DTSAV.BIN DTSAV.COM
; (or use the public domain utility EXE2COM and change the .EXE file
; directly to a .COM file, with this command:
; EXE2COM DTSAV
; )
; DEL DTSAV.OBJ
; DEL DTSAV.EXE
;
;Toad Hall Note:
; Updates include:
; Changing to file handles throughout.
; Dumping all the old FCB-related stuff.
; New code to Asciify date and time numbers and stuff them into
; a clean little preformatted buffer.
CrLf equ 0A0DH ; Cr/Lf in lo/hi order
CodeSeg segment para
assume CS:CodeSeg, ss:CodeSeg, DS:CodeSeg, ES:CodeSeg
org 100H
DtSav: jmp Start
ErrorStr db 'DTSAV failed.',0DH,0AH,'$'
;This is the code fragment that'll be modified with the current date and time,
;and then written out to file as DT.COM.
CodeFrag:
mov ah,2AH ;set date
mov cx,0000H ;year (self-modifying)
year equ $-2 ;point to the integer
mov dx,0000H ;the month and day (self-modifying)
mon_day equ $-2 ;point to the integer
mov ah,2BH ;set date
int 21H
mov cx,0000H ;hours and minutes
hr_min equ $-2 ;point to the integer
mov dx,0000H ;seconds and hundredths
seconds equ $-2 ;point to the integer
mov ah,2DH ;set time
int 21H
Exit:
mov ax,4C00H ;terminate process
int 21H ;done
CODELENGTH equ $ - CodeFrag + 1 ;how much to write to DT.COM
DTA db 'C:\DT.COM',0 ;force to C drive, root directory
;If you don't want DT.COM written to C:\, change as you wish.
;This example writes DT.COM to the current drive/subdirectory:
;DTA db 'DT.COM',0 ; filename as AsciiZ string
handle dw ? ;file handle
Start:
mov ax,CS ;This is NOT really necessary...
mov DS,ax ;DS=CS
mov ES,ax ;ES=CS
mov ah,41H ;- delete any version of DT.COM
mov dx,offset DTA ;DS:dx points to DTA w/file name
int 21H ;don't care if it fails
mov ah,3CH ;- create entry for DT.COM
;DTA pointer still in DS:dx
xor cx,cx ;read/write attrib
int 21H
jb File_error ; failed
mov handle,ax ;remember the handle
call FixCode ; get date/time, stuff in code
call CloseF ; close the file
jnb Exit ; and terminate process if no error
File_error:
mov dx,offset ErrorStr ;File error msg
mov ah,9 ;display string
int 21H ;DOS
mov ax,4C02H ;error=critical device error
int 21H ;terminate process
;
;
FixCode proc near
mov ah,2AH ; get date
int 21H
;AL=day of week
;CX=year
;DX=month day
mov word ptr year,cx ;stuff in our little code fragment
mov word ptr mon_day,dx ;month/day also
mov ah,2CH ; get time
int 21H
;CX=hours minutes
;DX=seconds deciseconds
mov word ptr hr_min,cx ;stuff in our little code fragment
mov word ptr seconds,dx
ret
FixCode endp
CloseF proc near
mov bx,handle ;get handle back
mov cx,CODELENGTH ;length of our subprogram code
mov dx,offset CodeFrag ;DS:dx pointer to our subprogram
mov ah,40H ;write to file or device
int 21H ;write out the block
jb CloseX ;error, return with carry set
mov ah,3EH ;close file handle (still in bx)
int 21H ;close up file
CloseX: ret
CloseF endp
CodeSeg ends
end DtSav